﻿#ifndef SPECTROMETERCONTROL_H
#define SPECTROMETERCONTROL_H

#include <QObject>
#include "BaseSpectroMeter.h"
#include "SpectroMeter/spectrometerdata.h"
#include "BaseDevice.h"

class BaseSpectroMeter;

class SpectroMeterControl : public BaseDevice
{
    Q_OBJECT
private:
    SpectroMeterControl();
    SpectroMeterControl(const SpectroMeterControl&)=delete;
    SpectroMeterControl& operator =(const SpectroMeterControl&)=delete;
    ~SpectroMeterControl();

public:
    static SpectroMeterControl& Instance();

    void EnumSpectroMeter(QList<AvsInfo>& avsInfos);
    const AvsMeasPara GetMeasPara();

    bool SetTriggerMode(bool isSoft);
    bool StartMeasure();
    bool ClearData();
    bool StopMeasure();
    bool SoftTrigger();

    QList<BaseSpectroMeter*> UpdateAllMeter();

    QList<SpectroInfoTag> GetSpectroMeterInfo();
    AvsMeasResultList ReadData(bool removeBase=true);

    BaseSpectroMeter* GetSpectroMeter(int index);

    virtual bool Stop() override;

public slots:
    void OnDataReveiveHandle(AvsMeasResult data);

private:
     QList<BaseSpectroMeter*> _allSpectroMeters;
     QList<QString> _allSpectroMeterSNs;
     AvsMeasResultList _receiveDataNew;
     QList<AvsMeasResult> _receiveData;

     // BaseDevice interface
     BaseSpectroMeter * CreateMeter();

     void ClearAllMeter();

//public:
//     void SetOtherConfig(QJsonObject config) override;
};

#endif // SPECTROMETERCONTROL_H
